Skip to content

Conversation

kl52752
Copy link
Contributor

@kl52752 kl52752 commented Aug 11, 2025

What type of PR is this?

/kind test
What this PR does / why we need it:
Add Conformance tests for BackendTLSPolicy validating SANs set with Type dns name
Which issue(s) this PR fixes:

Relates to #3979

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 11, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @kl52752. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 11, 2025
@kl52752
Copy link
Contributor Author

kl52752 commented Aug 11, 2025

/assign @robscott @candita @snorwin

@mikemorris
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 12, 2025
Copy link
Member

@robscott robscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kl52752!


// Verify that request sent to Service targeted by BackendTLSPolicy with mismatched SAN should failed.
t.Run("HTTP request send to Service targeted by BackendTLSPolicy with mismatched SAN should return HTTP error", func(t *testing.T) {
h.MakeRequestAndExpectFailure(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this will pass if any non-200 error code is returned. Can we be more specific here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the spec is a bit vague here, error codes are not constrained but it is up to implementation how to signal the error

Comment on lines 287 to 290
subjectAltNames:
- type: Hostname
hostname: abc.example.com
hostname: "mismatch.example.com"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it's testing a config mismatch instead of a mismatch in the cert itself. Can we also include a test that covers a case where the config lines up but the cert served by the backend does not match either the configured hostname or the SANs?

@kl52752 kl52752 marked this pull request as draft August 12, 2025 08:37
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 12, 2025
@kl52752 kl52752 marked this pull request as ready for review August 12, 2025 15:58
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 12, 2025
@kl52752 kl52752 force-pushed the san-tests branch 3 times, most recently from b4f63d3 to 34f8d3b Compare August 20, 2025 09:36
@snorwin
Copy link
Member

snorwin commented Aug 20, 2025

Thanks a lot @kl52752! I have verified the tests using the Airlock Microgateway.

@rikatz, if you wouldn’t mind verifying them with Envoy Gateway too, that would be really appreciated. Please feel free to unhold the PR afterwards.

/lgtm
/hold

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Aug 20, 2025
@snorwin
Copy link
Member

snorwin commented Aug 20, 2025

/assign @robscott

@@ -389,6 +389,11 @@ func (suite *ConformanceTestSuite) Setup(t *testing.T, tests []ConformanceTest)
suite.Applier.MustApplyObjectsWithCleanup(t, suite.Client, suite.TimeoutConfig, []client.Object{caConfigMap}, suite.Cleanup)
secret = kubernetes.MustCreateCASignedCertSecret(t, "gateway-conformance-infra", "tls-checks-certificate", []string{"abc.example.com"}, ca, caPrivKey)
suite.Applier.MustApplyObjectsWithCleanup(t, suite.Client, suite.TimeoutConfig, []client.Object{secret}, suite.Cleanup)
// TODO(kl52752) Merge CA certificates for Backend TLS Policy and move Deployment to common file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kl52752 I could take care of this, since I’m already planning a small refactoring in #3993.

@rikatz
Copy link
Contributor

rikatz commented Aug 20, 2025

Thanks a lot @kl52752! I have verified the tests using the Airlock Microgateway.

@rikatz, if you wouldn’t mind verifying them with Envoy Gateway too, that would be really appreciated. Please feel free to unhold the PR afterwards.

can do, adding to my queue
/cc
/assign

@robscott
Copy link
Member

Thanks @kl52752! @rikatz feel free to remove hold and merge if you're able to verify this with Envoy Gateway

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kl52752, robscott, snorwin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 20, 2025
@rikatz
Copy link
Contributor

rikatz commented Aug 20, 2025

envoy gateway fails to work, checking here if it is related to the gateway itself or something with tests

    --- FAIL: TestConformance/BackendTLSPolicySANValidation (3.33s)
        --- PASS: TestConformance/BackendTLSPolicySANValidation/HTTP_request_sent_to_Service_with_valid_BackendTLSPolicy_containing_dns_SAN_should_succeed (0.02s)
        --- FAIL: TestConformance/BackendTLSPolicySANValidation/HTTP_request_sent_to_Service_targeted_by_BackendTLSPolicy_with_mismatched_dns_SAN_should_return_an_HTTP_error (0.00s)
        --- PASS: TestConformance/BackendTLSPolicySANValidation/HTTP_request_sent_to_Service_with_valid_BackendTLSPolicy_containing_uri_SAN_should_succeed (0.01s)
        --- FAIL: TestConformance/BackendTLSPolicySANValidation/HTTP_request_sent_to_Service_targeted_by_BackendTLSPolicy_with_mismatched_uri_SAN_should_return_an_HTTP_error (0.00s)
        --- PASS: TestConformance/BackendTLSPolicySANValidation/HTTP_request_sent_to_Service_with_valid_BackendTLSPolicy_containing_multi_SAN_should_succeed (0.01s)
        --- FAIL: TestConformance/BackendTLSPolicySANValidation/HTTP_request_sent_to_Service_targeted_by_BackendTLSPolicy_with_mismatched_multi_SAN_should_return_an_HTTP_error (0.00s)

@rikatz
Copy link
Contributor

rikatz commented Aug 20, 2025

@snorwin @kl52752 from my tests it seems that the expected behavior of envoy-gateway failing to send the request to a backend because the certs don't match is not being respected by envoy gateway.

edit: just clarifying, this seems to me a lack of conformance on envoy gateway, the test seems fine. Did we tested with Istio as well?

/cc @candita
for some final thoughts

@k8s-ci-robot k8s-ci-robot requested a review from candita August 20, 2025 17:17
@rikatz
Copy link
Contributor

rikatz commented Aug 20, 2025

Tried to test with Istio as well, and miserably failed (probably my own fault)

Installed with istioctl install --set profile=preview --skip-confirmation and it couldn't reconcile backendtlspolicy, maybe I should be using some nightly version

@snorwin
Copy link
Member

snorwin commented Aug 20, 2025

I also tried testing it with kgateway, but without success. It seems that most implementations are not yet fully conformant with the BackendTLSPolicy specification, since we only recently began developing conformance tests.

@rikatz
Copy link
Contributor

rikatz commented Aug 20, 2025

/lgtm
Did some tests and couldn't make it work but because the services I tried are not conformant with this validation.

Please wait for Candace's unhold :)

@snorwin
Copy link
Member

snorwin commented Aug 25, 2025

/assign @shaneutt

@shaneutt shaneutt added the v1.4-release/subtask This indicates a subtask of a feature, bug, or smaller issue for the v1.4 release. label Aug 25, 2025
@shaneutt shaneutt moved this to Review in Release v1.4.0 Aug 25, 2025
@shaneutt shaneutt added this to the v1.4.0 milestone Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/test lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. v1.4-release/subtask This indicates a subtask of a feature, bug, or smaller issue for the v1.4 release.
Projects
Status: Review
Development

Successfully merging this pull request may close these issues.

8 participants